﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Sealight.Core.Domain
{
    public class ProductEntity:BaseEntity
    {       
        public virtual Guid ProductID { get; set; }
        public virtual string Name { get; set; }
        public virtual string ShortDescription { get; set; }
        public virtual string FullDescription { get; set; }
        public virtual bool ShowOnHomePage { get; set; }
        public virtual string MetaKeywords { get; set; }
        public virtual string MetaDescription { get; set; }
        public virtual string MetaTitle { get; set; }
        public virtual string SEName { get; set; }
        public virtual bool AllowReviews { get; set; }
        public virtual bool AllowRatings { get; set; }
        public virtual int RatingSum { get; set; }
        public virtual int TotalRatingVotes { get; set; }
        public virtual bool Published { get; set; }
        public virtual bool Deleted { get; set; }
        public virtual bool SysDefined { get; set; }
        public virtual DateTime CreatedDate { get; set; }
        public virtual DateTime ModifiedDate { get; set; }

        public virtual ProductTypeEntity ProductType { get; set; }
        public virtual IList<PictureEntity> Pictures { get; set; }
        public virtual IList<ProductCategoryEntity> CategoryMaps { get; set; }
        public virtual IList<ProductVariantEntity> ProductVariants { get; set; }
        public virtual Sealight.Core.DataAdapter.product ToDataAdapter()
        {
            DataAdapter.product data=new DataAdapter.product {id=this.ProductID, name = this.Name, allow_ratings=this.AllowRatings, allow_reviews=this.AllowReviews,
            created_date=this.CreatedDate, deleted=this.Deleted, full_description=this.FullDescription, meta_description = this.MetaDescription, metaTitle = this.MetaTitle,
            modified_date=this.ModifiedDate, meta_keywords=this.MetaKeywords, published=this.Published, rating_sum = this.RatingSum, se_name=this.SEName, short_description = this.ShortDescription,
                                                              show_on_home_page = this.ShowOnHomePage,
                                                              total_rating_votes = this.TotalRatingVotes,
                                                              type = this.ProductType.ToDataAdapter(),
                                                              sys_defined = this.SysDefined
            };
            if (this.Pictures != null)
                data.pictures = (from c in this.Pictures select c.ToDataAdapter()).ToList();
            if (this.ProductVariants != null && this.ProductVariants.Count > 0)
                data.product_variants = (from c in this.ProductVariants select c.ToDataAdapter()).ToList();
            if (this.CategoryMaps != null)
                data.category_maps = (from c in this.CategoryMaps select c.ToDataAdapter()).ToList();

            return data;
        }
    }
}
